package mysql

import (
	"gorm.io/gorm"
)

type User struct {
	gorm.Model
	Tel    string `gorm:"type:varchar(20);not null;index:ip_idx"`
	Status int64  `gorm:"type:int(20);not null;"`
}

func (u *User) List(status int64) (list []*User, err error) {
	err = DB.Where("status = ?", status).Find(&list).Error
	return
}
func (u *User) Update(userid int64) error {
	DB.Where("id = ?", userid).Find(&u)
	if u.Status == 0 {
		u.Status = 1
		return DB.Updates(&u).Error
	} else if u.Status == 1 {
		u.Status = 0
		return DB.Updates(&u).Error
	}
	return nil

}
